package com.situ.web.util;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class JSONUtil {

	public static void obj2Json(HttpServletResponse resp,Object object) throws IOException {
		JSONObject jsonObject = JSONObject.fromObject(object);
		resp.setContentType("text/html;charset=utf-8");
		resp.getWriter().write(jsonObject.toString());
	}
	
	public static void arrayJson(HttpServletResponse resp, Object object) throws IOException {
		JSONArray jsonArray = JSONArray.fromObject(object);
		resp.setContentType("text/html;charset=utf-8");
		resp.getWriter().write(jsonArray.toString());
	}
}
